<template>
  <div class="wrapper">
    <common-loading v-if="loading"></common-loading>
    <van-empty v-show="Null"
      class="custom-image"
      description="当前暂无发布记录"
      :image="nullImg"
    />
    <ul>
      <li v-for="(item, index) in list" :key="index" :id="item.store_id">
        <img onerror="this.src='../../../assets/img/news.png'" v-lazy="imgs(item.store_images.split(',')[0])">
        <div class="left_info">
          <div class="title">{{item.store_title}}</div>
          <div class="zi_26 hui_6">行业：<span class="hei_zi">{{item.store_category}}</span></div>
          <div class="zi_26 hui_6">区域：<span class="hei_zi">{{item.store_quyu}}</span></div>
          <div class="zi_26 hui_6">建筑面积：<span class="hong_zi jiacu">{{item.store_area}}㎡</span></div>
        </div>
        <router-link tag="div" :to="'/shopDetails/' + item.store_id" class="chakan" >查看</router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import {formatDate} from '../../../utils/formatDate.js'
import CommonLoading from '../../../common/Loading'
export default {
  name: 'CompanyShops',
  components: {
    CommonLoading
  },
  data () {
    return {
      loading: true,
      Null: false,
      nullImg: require('../../../assets/img/null.png'),
      is_fabu: false,
      list: []
    }
  },
  mounted () {
    this.postList()
  },
  methods: {
    imgs (img) {
      let newStr = img.indexOf('http')
      if (newStr !== 0) {
        return this.baseUrl + img
      } else {
        return img
      }
    },
    getTime (updatetime) {
      updatetime = updatetime * 1000
      let date = new Date(updatetime)
      return formatDate(date, 'yyyy/MM/dd')
    },
    postList () {
      this.loading = true
      this.$axios.post(process.env.API_HOST + '/api/vip/user_watch_log', {
        type: 1,
        limit: 50,
        page: 1
      }).then(this.postListSucc)
        .catch(error => console.log(error))
    },
    postListSucc (res) {
      if (res.data.code === 1) {
        this.loading = false
        this.list = res.data.data.lists
        if (res.data.data.count < 1) {
          this.Null = true
        } else {
          this.Null = false
        }
      }
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="stylus" scoped>
.wrapper
  width 100%
  padding-top 1rem
  padding-left .4rem /* 20/50 */
  padding-right .4rem /* 20/50 */
  ul
    background #F8F8F8
    li
      width 100%
      padding .3rem /* 15/50 */ 0rem /* 20/50 */
      background #fff
      position relative
      border-bottom 1px solid rgba(0,0,0,.1)
      img
        float left
        border-radius .1rem /* 5/50 */
        width 34%
        height 1.9rem /* 95/50 */
        object-fit cover
      .left_info
        width 100%
        padding-left 36%
        height 1.9rem /* 95/50 */
        .title
          font-size .32rem /* 16/50 */
          font-weight bold
          text-overflow -o-ellipsis-lastline
          overflow hidden
          text-overflow ellipsis
          display -webkit-box
          -webkit-line-clamp 1
          line-clamp 1
          -webkit-box-orient vertical
          line-height .52rem /* 26/50 */
          margin-bottom .1rem /* 10/50 */
        .zi_26
          height .44rem /* 22/50 */
          line-height .44rem /* 22/50 */
      .chakan
        position absolute
        bottom .3rem /* 15/50 */
        right 0rem /* 0/50 */
        width 1.12rem /* 56/50 */
        height .5rem /* 25/50 */
        line-height .5rem /* 25/50 */
        border:1px solid #999999
        border-radius .26rem /* 13/50 */
        text-align center
        color #999999
        font-size .26rem /* 13/50 */
  .van-empty
    padding 1.2rem /* 60/50 */ 0
    /deep/ .van-empty__image
      width 5.64rem /* 282/50 */
      height 4.72rem /* 236/50 */
      img
        width 100%
        height auto
    /deep/ .van-empty__description
      margin-top -.76rem /* 38/50 */
      padding 0px
      padding-left .26rem /* 13/50 */
      font-size .3rem /* 15/50 */
      color #656565
</style>
